<?php
class Third_Form_Upload extends Third_Form_Pattern {
	
	private $view;
	
	public function __construct( $name , $options ){
		parent::__construct( $name , $options );
		$this->field = new Zend_Form_Element_File( $this->name );
	}

	function setPattern( $pattern ) {
		$pattern = strtolower( $pattern );

		//$this->view  =  Zend_Registry::get('view');
		//$this->third =  Zend_Registry::get('third');	

		//$scriptUrl = $this->third->config->url_root.'/'.$this->third->config->jsUploadFile;
	
		switch( $pattern ){
			case 'uniqueimage': //UPLOAD'
			/*
			$this->view->headScript()->appendFile( $scriptUrl, $type = 'text/javascript', $attrs = array('rel'=>'forceLoad') );
			$this->view->headStyle()->appendStyle('@import url("'.$this->third->config->url_root.'/static/css/uploadify.css");');

			// INICIA A CAPTURA DE DADOS PARA UPLOAD COM FLASH
			$this->view->headScript()->captureStart();
			echo "

			window.fileUpload_fileDesc 			= 'Escolha uma imagem';
			window.fileUpload_fileExt			= '*.jpg;*.png;*.gif,*.bmp';
			window.fileUpload_multi   			= true;
			window.fileUpload_buttonText		= 'Adiciona imagem';
			window.fileUpload_simUploadLimit 	= 3;
			window.fileUpload_maxQueueSize 		= 1;
			window.fieldUpload 					= '$this->name'; 

			$(document).ready(function() {
					$('#".$this->name."').fileUpload({
						  'uploader': fileUpload_uploader
						, 'script': '/socialbase/sistema/profile/gedalias/edit-image-do'
						, 'folder': fileUpload_folder
						, 'cancelImg': fileUpload_cancelImg
						, 'fileDesc': fileUpload_fileDesc
						, 'fileExt': fileUpload_fileExt
						, 'multi': fileUpload_multi
						, 'buttonText': fileUpload_buttonText
						, 'width': fileUpload_width
						, 'height': fileUpload_height
						, 'maxQueueSize' : fileUpload_maxQueueSize
						, 'sizeLimit': fileUpload_sizeLimit
						, onCompleteAll: function(){
							alert('teste');
						}
					});
				}); ";

				$this->view->headScript()->captureEnd();
			*/

			$this->field->addValidator('IsImage', false);
			$this->field->addValidator('MimeType', false, array('image/gif', 'image/jpeg', 'image/png') );
			$this->field->addValidator('Size', false, 1000000);
				
			break;	
		}
	}
}
?>